<!DOCTYPE html>
<html lang="en">

<head>
  <title>Tammy</title>
  <script type="text/javascript" src="/tammy.js"></script>
  <script type="text/javascript" src="/tammy-adapter-xhr.js"></script>
  <script type="text/javascript">
    var http = tammy.http;
    var cancel = tammy.cancel;
    var token, token2;
    http.defaults.adapter = tammyAdapterXhr;
    http({
      url: '/tammy-adapter-xhr.js',
      responseType: 'text'
    }).then(function (res) {
      console.log(res);
    });
    http({
      url: '/api/sleep200',
      cancelToken: function (t) {
        token = t;
      }
    }).catch(function (err) {
      console.log(1, err);
    });
    cancel(token, '中断请求');

    http({
      url: '/api/sleep2000',
      cancelToken: function (t) {
        token2 = t;
      }
    }).catch(function (err) {
      console.log(2, err);
    });
    setTimeout(function () {
      cancel(token2, '中断请求2');
    }, 1000);
  </script>
</head>

<body>
  <div></div>
</body>

</html>
